package action;

import com.opensymphony.xwork2.ActionSupport;
import service.LoginService;

public class LoginAction extends ActionSupport {
    private String username;
    private String password;
    private LoginService ls;

    @Override
    public String execute() throws Exception {
        if(username == null || password == null){
            return "index";
        }else if (ls.validLogin(username,password)>0){
            addActionMessage("组件注入成功！");
            return SUCCESS;
        }
        addActionError("登陆失败！组件注入成功!");
        return ERROR;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setLs(LoginService ls) {
        this.ls = ls;
    }
}
